<?php

class dropTable
{
    var $dbName;
    function structure() {
        global $con, $HTTP_POST_VARS;
        $save_data = "on";
        $save_tables = "on";
        $out="";
        $res=mysql_list_tables($this->dbName);
        $nt=mysql_num_rows($res);
        for ($a=0;$a<$nt;$a++) {
            $row=mysql_fetch_row($res);
            $tablename=$row[0];
			//if(($tablename=="TblArchive_Lowest_00") || ($tablename=="TblArchive_Lowest_01") || ($tablename=="TblArchive_Lowest_02") || ($tablename=="TblArchive_Lowest_03") || ($tablename=="TblArchive_Lowest_PC_03") || ($tablename=="TblArchive_Today_02") || ($tablename=="TblArchive_Today_03") || ($tablename=="TblArchive_Today_PC_03"))
			//{
			//	continue;
			//}
			$out .= "\nDROP TABLE IF EXISTS `". $tablename."`; \n\n";
			$res2=mysql_query('SHOW CREATE TABLE ' . $this->dbName . '.' . $tablename);
            $tmpres        = mysql_fetch_array($res2);
            if(isset($save_tables) && $save_tables == "on") {
                $out .= $tmpres[1];
                $out .= "\n\n";
            }
            if(isset($save_data) && $save_data == "on") {
                $res2=mysql_query("select * from `$tablename`");
                $nf=mysql_num_fields($res2);
                $nr=mysql_num_rows($res2);
                for ($c=0;$c<$nr;$c++){
                    $out .= "insert into `$tablename` values (";
                    $row=mysql_fetch_row($res2);
                    for ($d=0;$d<$nf;$d++) {
                        $data=strval($row[$d]);
                        $out .="'".mysql_escape_string($data)."'";
                        if ($d<($nf-1)) {
                            $out .=", ";
                        }
                    }
                $out .=");\n";
                }
            }
        }
    $out .= "";
    return $out;
    }
}
?>
